package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.hsc.yalebao.adapter.GetAgentProfitListAdapter;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.GetAgentProfitListBean;
import com.hsc.yalebao.model.GetAgentProfitListBeanModel;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import okhttp3.Call;

public class ShouYiFenXiActivity extends BaseActivity
{
  private static Context context;
  private String TAG = "ShouYiFenXiActivity";
  private GetAgentProfitListAdapter adapter;
  private Calendar calendar;
  private View emptyView;
  private EditText et_end_tiem;
  private ImageView img_xiala_year;
  private boolean isEnd = false;
  private boolean isRefesh = true;
  private ImageView iv_title_right;
  private PullToRefreshListView mPullRefreshListView;
  private int mYear;
  private int memberid;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
        CustomApplication.app.finishActivity(ShouYiFenXiActivity.this);
        return;
      case 2131099882:
      }
      ShouYiFenXiActivity.this.showyearPopwindow();
    }
  };
  private int page = 1;
  PopupWindow popupWindowstart;
  private ArrayList<GetAgentProfitListBeanModel> result = new ArrayList();
  private RelativeLayout rl_year;
  private TextView tv_tishi;

  private void GetAgentProfitList()
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    localHashMap.put("Page", this.page);
    localHashMap.put("Pagesize", "10");
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_GETNEWAGENTPROFITLIST);
    showLoadingDialog();
    RequestNet.get(context, AppConstants.URL_GET_GETNEWAGENTPROFITLIST, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        ShouYiFenXiActivity.this.dismissLoadingDialog();
        ShouYiFenXiActivity.this.mPullRefreshListView.onRefreshComplete();
        ShouYiFenXiActivity.this.mPullRefreshListView.setEmptyView(ShouYiFenXiActivity.this.emptyView);
        LogUtils.e(ShouYiFenXiActivity.this.TAG, "获取失败,获取代理商返利列表:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        ShouYiFenXiActivity.this.dismissLoadingDialog();
        ShouYiFenXiActivity.this.mPullRefreshListView.onRefreshComplete();
        LogUtils.d(ShouYiFenXiActivity.this.TAG, "result:" + paramAnonymousString);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
        {
          LogUtils.d(ShouYiFenXiActivity.this.TAG, "result:" + paramAnonymousString);
          ShouYiFenXiActivity.this.mPullRefreshListView.setEmptyView(ShouYiFenXiActivity.this.emptyView);
        }
        GetAgentProfitListBean localGetAgentProfitListBean;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localGetAgentProfitListBean = (GetAgentProfitListBean)localGson.fromJson(paramAnonymousString, GetAgentProfitListBean.class);
            if (localGetAgentProfitListBean == null)
            {
              ShouYiFenXiActivity.this.mPullRefreshListView.setEmptyView(ShouYiFenXiActivity.this.emptyView);
              LogUtils.e(ShouYiFenXiActivity.this.TAG, "getAgentProfitListBean == null");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localGetAgentProfitListBean = null;
            }
            if (localGetAgentProfitListBean.getFlag() == 0)
            {
              ShouYiFenXiActivity.this.mPullRefreshListView.setEmptyView(ShouYiFenXiActivity.this.emptyView);
              LogUtils.e(ShouYiFenXiActivity.this.TAG, "getAgentProfitListBean.getFlag() ==0");
              return;
            }
            if (localGetAgentProfitListBean.getFlag() == -2)
            {
              ShouYiFenXiActivity.this.showDownWireDialog();
              return;
            }
            if (localGetAgentProfitListBean.getFlag() == -3)
            {
              ShouYiFenXiActivity.this.ShowFengjinDialog();
              return;
            }
            if (localGetAgentProfitListBean.getFlag() == -4)
            {
              ShouYiFenXiActivity.activityStack.backToMain(MainActivity.class, ShouYiFenXiActivity.context);
              return;
            }
          }
        }
        while (localGetAgentProfitListBean.getFlag() != 1);
        if (localGetAgentProfitListBean.getResult() == null)
        {
          LogUtils.e(ShouYiFenXiActivity.this.TAG, "getAgentProfitListBean.getResult() == null");
          return;
        }
        ShouYiFenXiActivity.this.result.addAll(localGetAgentProfitListBean.getResult());
        if ((ShouYiFenXiActivity.this.result == null) || (ShouYiFenXiActivity.this.result.size() == 0))
        {
          ShouYiFenXiActivity.this.tv_tishi.setText("暂无数据");
          ShouYiFenXiActivity.this.mPullRefreshListView.setEmptyView(ShouYiFenXiActivity.this.emptyView);
          LogUtils.e(ShouYiFenXiActivity.this.TAG, "result == null || result.size() == 0");
        }
        if (localGetAgentProfitListBean.getResult().size() < 10);
        for (ShouYiFenXiActivity.this.isEnd = true; ; ShouYiFenXiActivity.this.isEnd = false)
        {
          ShouYiFenXiActivity.this.adapter.setData(ShouYiFenXiActivity.this.result);
          ShouYiFenXiActivity.this.adapter.notifyDataSetChanged();
          return;
        }
      }
    });
  }

  private void init()
  {
    this.emptyView = LayoutInflater.from(context).inflate(2130903139, null);
    this.tv_tishi = ((TextView)this.emptyView.findViewById(2131100053));
    this.tv_tishi.setText("获取中...");
    this.mPullRefreshListView = ((PullToRefreshListView)findViewById(2131099717));
    this.mPullRefreshListView.setEmptyView(this.emptyView);
    this.mPullRefreshListView.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
    this.mPullRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener()
    {
      public void onRefresh(PullToRefreshBase<ListView> paramAnonymousPullToRefreshBase)
      {
        String str = DateUtils.formatDateTime(ShouYiFenXiActivity.this.getApplicationContext(), System.currentTimeMillis(), 524305);
        paramAnonymousPullToRefreshBase.getLoadingLayoutProxy().setLastUpdatedLabel(str);
        if (ShouYiFenXiActivity.this.mPullRefreshListView.isFooterShown())
        {
          LogUtils.e(ShouYiFenXiActivity.this.TAG, "mPullRefreshListView加载");
          ShouYiFenXiActivity localShouYiFenXiActivity = ShouYiFenXiActivity.this;
          localShouYiFenXiActivity.page = (1 + localShouYiFenXiActivity.page);
          ShouYiFenXiActivity.this.GetAgentProfitList();
        }
      }
    });
  }

  @SuppressLint({"NewApi"})
  @TargetApi(12)
  private void showyearPopwindow()
  {
    this.img_xiala_year.setImageResource(2130837882);
    View localView = LayoutInflater.from(context).inflate(2130903173, null);
    final PopupWindow localPopupWindow = new PopupWindow(localView, this.rl_year.getWidth(), 2 * this.rl_year.getHeight(), true);
    ListView localListView = (ListView)localView.findViewById(2131100233);
    int i = this.calendar.get(1);
    final String[] arrayOfString = new String[2];
    arrayOfString[0] = (i - 1);
    arrayOfString[1] = i;
    localListView.setAdapter(new ArrayAdapter(context, 2130903047, arrayOfString));
    localListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
      public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
      {
        try
        {
          ShouYiFenXiActivity.this.et_end_tiem.setText(arrayOfString[paramAnonymousInt] + "年");
          ShouYiFenXiActivity.this.img_xiala_year.setImageResource(2130837881);
          ShouYiFenXiActivity.this.GetAgentProfitList();
          localPopupWindow.dismiss();
          return;
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
        }
      }
    });
    localPopupWindow.setOutsideTouchable(true);
    localPopupWindow.setFocusable(true);
    localPopupWindow.setBackgroundDrawable(context.getResources().getDrawable(2130838170));
    localPopupWindow.showAsDropDown(this.et_end_tiem, 0, 0);
  }

  @TargetApi(19)
  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903084);
    CustomApplication.app.addActivity(this);
    context = this;
    setTitle(8, 0, 2130837809, "收益分析", 0, 8, 8, 0, true);
    this.calendar = Calendar.getInstance();
    this.rl_year = ((RelativeLayout)findViewById(2131099882));
    this.rl_year.setOnClickListener(this.onClickListener);
    this.img_xiala_year = ((ImageView)findViewById(2131099884));
    this.et_end_tiem = ((EditText)findViewById(2131099873));
    this.et_end_tiem.setInputType(0);
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    init();
    GetAgentProfitList();
  }

  protected void onResume()
  {
    super.onResume();
    if (this.adapter == null)
    {
      this.adapter = new GetAgentProfitListAdapter(context, this.result);
      this.mPullRefreshListView.setAdapter(this.adapter);
    }
    this.adapter.notifyDataSetChanged();
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.ShouYiFenXiActivity
 * JD-Core Version:    0.6.2
 */